<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/script/jquery-3.1.0.min.js"></script>
<script type="text/javascript">
	$(function() {
		$("#testJsonResponse").click(function(event) {
			event.preventDefault();			
			$.ajax({
				url: this.href,
				method: 'POST',
				async: false,
				success: function(data) {
					if(data != null) {
						for(var i = 0; i < data.length; i ++) {
							var tr = "<tr class=\"textAlignCenter\">";
							tr += "<td>" + data[i].userName +"</td>";
							tr += "<td>" + data[i].password +"</td>";
							tr += "<td>" + data[i].sex +"</td>";
							tr += "<td>" + data[i].email +"</td>";
							tr += "<td>路径设置有问题</td>";
							tr += "</tr>";
							$("#table").append(tr);
						}
					}
				}
			})
		});
	});
</script>
<style type="text/css">
	.textAlignCenter {
		text-align: center;
	}
	.bigFont {
		font-size: large;
	}
</style>
</head>

<body>
	<!-- @RequestMapping 的使用示例  -->
	<a class="bigFont" href = "/SpringMVC/requestMapping/helloWorld">hello world!</a>	<br /><br />
	
	<!-- @PathVariable的使用示例  -->
	<a class="bigFont" href = "/SpringMVC/PathVariableRestDemo/testPathVariable/dingdongfang">testPathVariable</a><br /><br />
	
	<!-- @PathVariable的使用示例  -->
	<a class="bigFont" href = "/SpringMVC/PathVariableRestDemo/testPathVariable2/dingdongfang/ddf">testPathVariableTwo</a><br /><br />
	
	<!-- @PathVariable的使用示例  -->
	<form action = "/SpringMVC/PathVariableRestDemo/testRestMethodPost/100" method = "POST">
		<input type = "submit" value = "submit post">
	</form>
	<br/><br />
	
	<!-- @PathVariable配合转换POST请求为DELETE请求的使用示例  -->
	<form action = "<%=request.getContextPath()%>/PathVariableRestDemo/testRestMethodDelete/100" method = "POST">
		<input type = "hidden" name = "_method" value = "DELETE">
		<input type = "submit" value = "submit delete">
	</form>
	<br/>
	
	<!-- RequestParams的使用示例 -->
	<form action = "<%=request.getContextPath()%>/requestParamDemo/testRequestParams" method = "POST">
		userName: <input type = "text" name = "userName" />
		age: <input type = "text" name = "age" />
		<input type = "submit" value = "submit testRequestParams">
	</form>
	
	<br/>
	<!-- RequestHeader的使用示例 -->
	<form action = "<%=request.getContextPath()%>/requestParamDemo/testRequestHeader" method = "POST">
		<input type = "submit" value = "submit testRequestHeader">
	</form>
	<br/>
	
	<!-- @CookieValue的使用示例 -->
	<form action = "requestParamDemo/testCookieValue" method = "POST">
		<input type = "submit" value = "submit testCookieValue">
	</form>
	<br />
	
	<!-- POJO对象的参数获取 -->
	<form action = "requestParamDemo/testPojoParams" method = "POST">
		userName: <input type = "text" name = "userName" />
		sex: <input type = "text" name = "sex" />
		email: <input type = "text" name = "email" />
		province: <input type = "text" name = "address.province" />
		city： <input type = "text" name = "address.city" />
		<input type = "submit" value = "submit testPojo">
	</form>
	<br />
	
	<!-- 使用原生Servlet API -->
	<form action = "requestParamDemo/testServletAPI" method = "POST">
		userName: <input type = "text" name = "userName" />
		age: <input type = "text" name = "age" />
		<input type = "submit" value = "submit testServletAPI">
	</form>
	<br />
	
	<!-- ModelAndView的使用示例 -->
	<form action = "<%=request.getContextPath()%>/modelAndViewDemo/testModelAndView" method = "POST">
		userName: <input type = "text" name = "userName" />
		sex: <input type = "text" name = "sex" />
		email: <input type = "text" name = "email" />
		province: <input type = "text" name = "address.province" />
		city： <input type = "text" name = "address.city" />
		<input type = "submit" value = "submit ModelAndView">
	</form>
	<br />
	
	<!-- ViewAndMap的使用示例 -->
	<form action = "<%=request.getContextPath()%>/modelAndViewDemo/testViewAndMap" method = "POST">
		userName: <input type = "text" name = "userName" />
		age: <input type = "text" name = "age" />
		<input type = "submit" value = "submit ViewAndMap">
	</form>
	<br /> <br />
	
	<!-- @SessionAttributes的使用示例 -->
	<form action = "<%=request.getContextPath()%>/modelAndViewDemo/testSessionAttributes" method = "POST">
		userName: <input type = "text" name = "userName" />
		sex: <input type = "text" name = "sex" />
		email: <input type = "text" name = "email" />
		province: <input type = "text" name = "address.province" />
		city： <input type = "text" name = "address.city" />
		<input type = "submit" value = "submit testSessionAttributes">
	</form>
	<br />
	<!-- ModelAttriubtes使用示例 ,不传入password属性-->
	<form action = "<%=request.getContextPath()%>/ModelAttributesDemo/testModelAttributes" method = "POST">
		<input type = "hidden" name = "id" value = "1"/>
		userName: <input type = "text" name = "userName" />
		sex: <input type = "text" name = "sex" />
		email: <input type = "text" name = "email" />
		<input type = "submit" value = "submit ModelAttributes">
	</form>
	<br />
	
	<!-- 自定义视图解析器 -->
	<form action = "<%=request.getContextPath()%>/modelAndViewDemo/testXmlView" method = "POST">
		userName: <input type = "text" name = "userName" />
		password: <input type = "text" name = "password" />
		sex: <input type = "text" name = "sex" />
		email: <input type = "text" name = "email" />
		<input type = "submit" value = "submit testXmlView">
	</form>
	<br />
	
	<!-- 自定义格式转换器 -->
	<form action="${pageContext.request.contextPath}/ConverServiceDemo
		/testUserConversionDemo" method="POST">
		<!-- id: 1, userName: ddf, password: 123456, sex: nan -->
		<input type = "text" name = "user" value = "1/ddf/123456/nan">	
		<input type = "submit" value = "submit userConversionDemo">
	</form>
	<br />
	
	<!-- Rest风格CRUD -->
	<a href = "<%=request.getContextPath()%>/userService/getAllUsers"
				class="bigFont">show all users</a>
	<br /><br />
	
	<!-- 返回json对象数组 -->
	<a id = "testJsonResponse" href = "${pageContext.request.contextPath}/requestResponseBodyDemo/
			testResponseJson" class="bigFont">@responseBody test Json</a>
	<table id = "table" border = "1" cellpadding="0" cellspacing="0" width="600">
		<tr class="textAlignCenter">
			<th width="15%">userName</th>
			<th width="15%">password</th>
			<th width="15%">sex</th>
			<th width="25%">email</th>
			<th width="30%">operate</th>
		</tr>
		<%-- <tr class="textAlignCenter">
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td><a href="${pageContext.request.contextPath}/userService/
						getUserById/${user.id}">编辑</a>&nbsp;|&nbsp;
				<a id = "deleteUserById" href="${pageContext.request.contextPath}/userService/
						deleteUserById/${user.id}">删除</a>
			</td>
		</tr> --%>
	</table>
	<br/> <br/>
	
	<!-- 自定义拦截器 -->
	<form action="${pageContext.request.contextPath}/userService/testInterceptor">
	userName: <input type = "text" name = "userName" value="${user.userName}"/>	<br/><br/>
	password: <input type = "text" name = "password" value="${user.password}"/>	<br/><br/>
	&nbsp;&nbsp;&nbsp;sex:<input type = "text" name = "sex" value="${user.sex}"/>	<br/><br>
	&nbsp;&nbsp;email:<input type = "text" name = "email" value="${user.email}"/>	<br/><br/>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id = "submit" type = "submit" value = "submit"/>
	
	<br/> <br/>
	<!-- 测试自定义的参数的拦截和封装 -->
	<a href = "${pageContext.request.contextPath }/testRequestContext/testParams?username=admin">测试自定义的参数的拦截和封装</a> <br/>
</form>
 </body>
</html>